package testMybatis;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.dao.PermissionDao;
import com.itheima.dao.RoleDao;
import com.itheima.dao.UserDao;
import com.itheima.pojo.Permission;
import com.itheima.pojo.Role;
import com.itheima.pojo.SysUser;
import com.itheima.service.UserService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.Set;

/**
 * @ClassName test
 * @Description: TODO
 * @Author 郑乾
 * @Date 2020-07-04
 * @Version V1.0
 **/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:config/*")
public class test {
    @Autowired
    RoleDao roleDao;
    @Autowired
    PermissionDao permissionDao;
    @Autowired
    UserDao userDao;
    @Reference
    UserService userService;
    @Test
    public void test01(){
        Set<Role> rolesByUserId = roleDao.findRolesByUserId(1);
        for (Role role : rolesByUserId) {
            System.out.println(role.getName());
        }
        System.out.println("---------------------------");
        Set<Permission> permissionsByRoleId = permissionDao.findPermissionsByRoleId(1);
        for (Permission permission : permissionsByRoleId) {
            System.out.println(permission.getName());
        }
        SysUser admin = userDao.findByUsername("admin");
        System.out.println(admin);
    }
    @Test
    public void test02(){
        SysUser admin = userService.findByUsername("admin");
        System.out.println("admin = " + admin);
    }
}
